﻿<%@ Page Language="C#" MasterPageFile="~/Pages/Base/ListItemBase.master" CodeFile="~/Pages/Base/ListItemBase.cs" Inherits="ListItemBasePage" %>
<asp:Content ID="content" runat="server" ContentPlaceHolderID="footContent">
    <asp:HyperLink ID="addPMHyperLink" runat="server">新增篇名</asp:HyperLink>
 </asp:Content>
<asp:Content ID="message" runat="server" ContentPlaceHolderID="messageContent">
<asp:Label ID="errorLabel" runat="server" ForeColor="Red">
</asp:Label>
</asp:Content>
<script runat="server">
    
    /// <summary>
    /// 数据库交互对象
    /// </summary>

    private StateGrid.WWHY.WWHY_DAO dao=new StateGrid.WWHY.WWHY_DAO();

    private IList<StateGrid.WWHY.WWHY_PM> data;
    /// <summary>
    /// 索引编码
    /// </summary>
    private String sybm;

    protected override void DoInit()
    {
        //索引编码
        this.sybm = Request["sybm"];
        this.addPMHyperLink.NavigateUrl = StateGrid.GlobalVariables.GlobalWWHY.ADDPM_PAGE + "?sybm=" + this.sybm;
    }

    protected override void SetItemFields()
    {
        RegisterKeyField("wjm");
        
        AddBoudField("文件名", "wjm", 0,25);
        AddBoudField("外文篇名", "wwpm", 24,40);
        AddBoudField("作者", "zz", 10,25);
        
        AddHyperLinkField("修改",
                          StateGrid.GlobalVariables.GlobalWWHY.EDITPM_PAGE + "?wjm={0}",
                          new string[] {"wjm"}); 
    }

    protected override int GetItemCount()
    {
        return dao.countQueryWwhyPM(this.sybm);
    }

    protected override object GetItemSource(int begin, int end)
    {
        data = dao.queryWwhyPM(this.sybm, begin, end);
        return data;
    }

    protected override bool OnDelete(DataKey dataKey, out string message)
    {
        int ret = dao.deleteWwhyPMByWjm(dataKey.Value as string,((StateGrid.User.User)Session["login"]).name);

        if (ret >= 1)
        {
            message = "删除成功";
            return true;
        }

        message = "删除失败";
        return false;
    }

    //显示删除按钮
    protected override Boolean HasDeleteField()
    {
        return true;
    }
</script>
